A new property of the last non-zero digit of factorials
-------------------------------------------------------

    I discovered a property of the last non-zero digit of factorials of powers
of ten.

Property - If n is not equal to 1, the last non-zero digit of (10^n)! is equal
           to the last non-zero digit of (2^n)!.

    This property is interesting, and because 10^n grows much faster than 2^n,
it can be used to reduce drastically the execution time of computations of the
last non-zero digit of factorials. (In the particular case of factorials of N,
N a power of 10.)

    Given an integer N = 10^n, n >= 0, the value of the last non-zero digit of
N!, a(n), can be determined by the second formula of OEIS sequence A173670,
namely,

a(0) = 1, a(1) = 8, if n >= 2, with
2^n represented in base 5 as (a_h, ... ,a_1,a_0)5,
t = _sum{i = h, h-1, ... , 0} (a_i even),
x = _sum{i = h, h-1, ... , 1}( _sum{k = h, h-1, ... , i}(a_i) ),
z = (x + t/2) mod 4, and y = 2^z,
a(n) = 6(y mod 2) + y(1-(y mod 2)).

    To prove the validity of the given property we can show that the formula
above gives the same results when 10^n is used, instead of the actual term 2^n
appearing in the begining of the second line of the formula.

    Let x10 be the value of the sum x, when 10^n is used, instead of 2^n.

    For a given n, all the digits of (2^n)5 coincide, one by one, from left to
right, with the initial digits of (10^n)5, and n zeros appear in (10^n)5 after
those coincident digits, see A055476 for details. From this fact it is not
difficult to see that x10 satisfies the identity,

x10 = x + n*s,

where s is the sum of the digits of (2^n)5.

    The proof is complete since the value of z is not modified if 10^n replaces
2^n. Note that the sum t remains the same if we substitute 2^n by 10^n, and s
mod 4 = 0 because the digit sum of (2^n)5, s, is divisible by 4. See A053824.
***

    For example, let n=9. 2^9 = 512 = (4022)5, and 10^9 = (4022000000000)5. Note
that all the digits of (2^9)5 coincide, one by one, from left to right, with the
initial digits of (10^9)5, and n zeros appear in (10^9)5 after those coincident
digits.
    In this case h = 3, x = 4 + (4+0) + (4+0+2) = 14, s = 8, and t/2 = 4. We
have x10 = (4 + (4+0) + (4+0+2)) + (4+0+2+2) + 8(4+0+2+2) = x + 9s. The value of
z is 2. Note that z = (x + t/2) mod 4 = (x10 + t/2) mod 4 = (x + n*s + t/2) mod
4.
-----------------

    If one wants to found the last non-zero digit of (10^9)! by hand, it would
be nice to know that 2^9 can be used instead. Try to work with n = 12 two times,
in the first time use the given property, in the second ignore it. If in the
second time you do not cheat in the conversion of 10^12, alas computers and
ordinary people never work in quinary, you will work hard to complete the task.

-----------------

Related sequences about digit sums in quinary of numbers of the form 10^n,
10^n - 1, and 10^n + 1

A183226 Sum of digits of (10^n)5 = sum of digits of (2^n)5.
A183227 Sum of digits of (10^n - 1)5 = sum of digits of (2^n - 1)5 + 4n.
A183228 Digit sum of (10^n + 1)5 = digit sum of (2^n)5 + 1.
